using System.IO;
using System.Runtime.Serialization;
using ImageUploaderComponent.Extensions;

namespace ImageUploaderComponent.Data {
    /// <summary>
    /// Holds data for one logical set of images.  This class should be immutable.
    /// </summary>
    [DataContract]
    public class ImageData : MediaData{
        public ImageData() { }

        public ImageData(FileInfo file) {
            ImageTitle = file.Name.Split('.')[0];
            CommentText = "Type a Description";
            FileName = file.Name;
            isEnabled = true;
            if (file.Length>0){
                using (FileStream stream = file.OpenRead()){
                    imageBytes = stream.ToArray();
                }
            }
            
        }


        private string largeFileName;
        [DataMember]
        public string LargeFileName{
            get { return largeFileName; }
            set{
                largeFileName = value;
                changeProperty("LargeFileName");
            }
        }
    }
}